home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
United Public Domain Gold 4
/
United Public Domain Gold 4.iso
/
fredfish
/
ff.0014.dms
/
ff.0014.adf
/
pdterm
/
menus.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-04-10
|
5KB
|
200 lines
#include "term.h"
/* Dynamic Intuition Text functions */
struct IntuiText *NewIText(text, left, top)
char *text;
int left, top;
{
struct IntuiText *newtext = NULL;
newtext = (struct IntuiText *)AllocMem(sizeof(*newtext),
MEMF_PUBLIC | MEMF_CLEAR);
newtext->IText = (UBYTE *)text;
newtext->FrontPen = 0;
newtext->BackPen = 1;
newtext->DrawMode = JAM2;
newtext->LeftEdge = left;
newtext->TopEdge = top;
newtext->ITextFont = NULL;
newtext->NextText = NULL;
return(newtext);
}
struct IntuiText *AddIText(IText, text)
struct IntuiText *IText;
char *text;
{
struct IntuiText *newtext = NULL;
newtext = (struct IntuiText *)AllocMem(sizeof(*newtext),
MEMF_PUBLIC | MEMF_CLEAR);
newtext->IText = (UBYTE *)text;
newtext->FrontPen = IText->FrontPen;
newtext->BackPen = IText->BackPen;
newtext->DrawMode = IText->DrawMode;
newtext->LeftEdge = IText->LeftEdge;
newtext->TopEdge = IText->TopEdge + 11;
newtext->ITextFont = IText->ITextFont;
newtext->NextText = NULL;
IText->NextText = newtext;
return(newtext);
}
DisposeIText(IText)
struct IntuiText *IText;
{
struct IntuiText *current, *next;
current = IText;
for(next = current->NextText; current != NULL; next = next->NextText){
FreeMem(current,sizeof(*current));
current = next;
}
}
/* Dynamic Menu Constructor Functions */
#define InterMenuWidth 15
struct Menu *NewMenu(menuname, width, height)
char *menuname;
int width, height;
{
struct Menu *menu = NULL;
menu = (struct Menu *)AllocMem(sizeof(*menu),
MEMF_PUBLIC | MEMF_CLEAR);
menu->NextMenu = NULL;
menu->LeftEdge = 0;
menu->TopEdge = 0;
menu->Width = width;
menu->Height = height;
menu->Flags = MENUENABLED;
menu->MenuName = menuname;
menu->FirstItem = NULL;
return(menu);
}
struct Menu *AddMenu(menus, MenuName, width, height)
struct Menu *menus;
char *MenuName;
int width, height;
{
struct Menu *newmenu;
newmenu = NewMenu(MenuName, width, height);
newmenu->LeftEdge = menus->LeftEdge + menus->Width + InterMenuWidth;
menus->NextMenu = newmenu;
return(newmenu);
}
struct MenuItem *NewMenuItem(name, width, height)
char *name;
int width, height;
{
struct MenuItem *newitem = NULL;
struct IntuiText *NewIText(), *newtext = NULL;
newitem = (struct MenuItem *)AllocMem(sizeof(*newitem),
MEMF_PUBLIC | MEMF_CLEAR);
newtext = NewIText(name,0,1);
newitem->NextItem = NULL;
newitem->ItemFill = (APTR) newtext;
newitem->LeftEdge = 0;
newitem->TopEdge = 0;
newitem->Width = width;
newitem->Height = height;
newitem->Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP;
newitem->MutualExclude = 0;
newitem->SelectFill = NULL;
newitem->Command = 0;
newitem->SubItem = NULL;
newitem->NextSelect = 0;
return(newitem);
}
struct MenuItem *AddNewMenuItem(menu, name, width, height)
struct Menu *menu;
char *name;
int width, height;
{
struct MenuItem *newitem, *NewMenuItem();
newitem = NewMenuItem(name, width, height);
menu->FirstItem = newitem;
return(newitem);
}
struct MenuItem *AddItem(items, name)
struct MenuItem *items;
char *name;
{
struct MenuItem *newitem, *NewMenuItem();
newitem = NewMenuItem(name, items->Width, items->Height);
newitem->TopEdge = items->TopEdge + items->Height;
newitem->LeftEdge = items->LeftEdge;
items->NextItem = newitem;
return(newitem);
}
struct MenuItem *AddNewSubItem(item, name, width, height)
struct MenuItem *item;
char *name;
int width, height;
{
struct MenuItem *newitem, *NewMenuItem();
newitem = NewMenuItem(name, width, height);
item->SubItem = newitem;
newitem->LeftEdge = item->Width;
return(newitem);
}
DisposeItem(item)
struct MenuItem *item;
{
DisposeIText((struct ItuiText *)item->ItemFill);
FreeMem(item,sizeof(*item));
}
DisposeItems(items)
struct MenuItem *items;
{
struct MenuItem *current, *next;
current = items;
for(next = current->NextItem; current != NULL; next = next->NextItem){
DisposeItem(current);
current = next;
}
}
DisposeMenu(menu)
struct Menu *menu;
{
DisposeItems(menu->FirstItem);
FreeMem(menu,sizeof(*menu));
}
DisposeMenus(menus)
struct Menu *menus;
{
struct Menu *current, *next;
current = menus;
for(next = current->NextMenu; current != NULL; next = next->NextMenu){
DisposeMenu(current);
current = next;
}
}